
function Vue(obj){

    // this
    this.created = obj.created
    this.created()




    this.el = document.querySelector(obj.el)  //获取到元素
    this.data = obj.data
    this.YuanShi = this.el.innerHTML  //存原始值
    this.methods = obj.methods  //找寻传过来的函数


    // return this
    this.compile = function(){
        // 每次替换原始值
        this.el.innerHTML = this.YuanShi.replace(/\{\{(.+)\}\}/g,(all,group)=>{
            // all 代表所有的  group代表他的属性
            console.log(all,group);
            return this.data[group] 
        })
        console.log(this.el.innerHTML);
    }


    this.compile()  //执行  //渲染函数
    



    // this.jia = function (){
    //     this.data.age++
    //     this.compile()
    // }
    // this.jian = function (){
    //     this.data.age--
    //     this.compile()
    // }
    




    this.event = function(){
        this.el.onclick = (e)=>{
            let dianJi = e.target.getAttribute("@click")
            if(dianJi){

                this[dianJi.split("(")[0]]()
                
            }
        }
    }


    this.event()



    this.getMethods = e=>{  //循环绑定传过来的点击函数
        for (let item in this.methods) {
            this.__proto__[item] = this.methods[item]
            // 相当于执行了
            /**
             *     this.__proto__[jia] = function(){
                    this.data.age++   //年龄加，刷新页面
                    this.compile()
                },
            * 
            * 
            *  *     this.__proto__[jian] = function(){
                    this.data.age--   //年龄减，刷新页面
                    this.compile()
                },
            * 
            * 加到Vue这个构造函数的原型里面去了
            */

        }
    }
    this.getMethods()  //执行绑定
    

}



Vue.prototype = {
    getMethods(e){  //循环绑定传过来的点击函数
        for (let item in this.methods) {
            this.__proto__[item] = this.methods[item]
            // 相当于执行了
            /**
             *     this.__proto__[jia] = function(){
                    this.data.age++   //年龄加，刷新页面
                    this.compile()
                },
            * 
            * 
            *  *     this.__proto__[jian] = function(){
                    this.data.age--   //年龄减，刷新页面
                    this.compile()
                },
            * 
            * 加到Vue这个构造函数的原型里面去了
            */

        }
    },
}


let axios = {
    get:function(){
        return "hhaahhah"
    }
}

Vue.prototype.$http = axios